<!DOCTYPE HTML>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <title>微信连Wi-Fi</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/weixin/css/style-simple-follow.css"/>
	<script type="text/javascript" src="/weixin/js/wechatutil.js" ></script>
	<script src="/weixin/js/md5.min.js"></script>

	<script type="text/javascript">
        function getQueryString(name) {
            var reg = new RegExp("(^|&)"+ name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r != null)
                return unescape(r[2]);
            return null;
        }

        function asyncScript(url) {
            var script = document.createElement('script');
            script.setAttribute('src', url);
            document.getElementsByTagName('head')[0].appendChild(script);
        }

        function ajax(url, cb) {
            var xmlhttp = new XMLHttpRequest();

            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    cb(xmlhttp.responseText);
            };
            xmlhttp.open("GET", url, true);
            xmlhttp.send();
        }

		function startWeChatAuth() {
            ajax(window.location.origin + '/wifidog/weixincfg', function(responseText) {
                var cfg = JSON.parse(responseText);
                var appId = cfg.appid;
                var shopId = cfg.shopid;
                var secretkey = cfg.secretkey;
                var extend = 'demoNew';
                var timestamp = new Date().getTime();
                var authUrl = window.location.origin + '/wifidog/weixin' + window.location.search;
                var mac = getQueryString('mac').toLowerCase();
                var ssid = getQueryString('ssid');

                if (!ssid || ssid == '')
                    ssid = 'null';

                var sign = md5(appId + extend + timestamp + shopId + authUrl + mac + ssid + secretkey);
                Wechat_GotoRedirect(appId, extend, timestamp, sign, shopId, authUrl, mac, ssid);
            });
		}

        function temporary_pass() {
            var gw_address = getQueryString('gw_address');
            var gw_port = getQueryString('gw_port');
            asyncScript('http://' + gw_address + ':' + gw_port + '/wifidog/temppass?script=startWeChatAuth();');
        }
	</script>
</head>
<body class="mod-simple-follow">
<div class="mod-simple-follow-page">
    <div class="mod-simple-follow-page__banner">
        <img class="mod-simple-follow-page__banner-bg" src="/weixin/images/background.jpg" alt=""/>
        <div class="mod-simple-follow-page__img-shadow"></div>
        <div class="mod-simple-follow-page__logo">
            <img class="mod-simple-follow-page__logo-img" src="/weixin/images/t.weixin.logo.png" alt=""/>
            <p class="mod-simple-follow-page__logo-name"></p>
            <p class="mod-simple-follow-page__logo-welcome">欢迎您</p>
        </div>
    </div>
    <div class="mod-simple-follow-page__attention">
        <p class="mod-simple-follow-page__attention-txt">欢迎使用微信连Wi-Fi</p>
        <a class="mod-simple-follow-page__attention-btn" onclick="temporary_pass()">一键打开微信连Wi-Fi</a>
    </div>
</div>
</body>

</html>
